* Load dataset
use "replication data - main.dta", clear

log using "table A5-A27.txt", text replace
log off

preserve
keep if year >1990	

gen Islamist_attk = ln_Islamattk1yr
gen nonIslamist_attk = ln_nonIslamattk1yr

gen Islamist_terror = ln_Islamkill1yr
gen nonIslamist_terror = ln_nonIslamkill1yr 


local main 			"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition"
local inter_west	"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition##i.western"
local inter_911		"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition##i.post911"
local inter_igo		"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition##i.igo"
local main_attk		"(c.Islamist_attk   c.nonIslamist_attk)##i.islamic_opposition"
local main_D		"(i.Islamist_terror_D i.nonIslamist_terror_D)##i.islamic_opposition"

local controls 		"c.problems muslim00 c.polity2 polity2_change ln_mortality firstmpany transitional_election postconflict pre_election_violence ln_oil lln_total_trade col_any postcoup ln_gdptotal legelec"

	
************
* TABLE A5 *	
************
	
* ologit: All countries
ologit a1 `main' `controls' , cl(ccode)
est store olgt_all_a5

* ologit: West vs Rest
ologit a1 `main' `controls' if western==1 , cl(ccode)
est store olgt_west_a5

ologit a1 `main' `controls' if western==0 , cl(ccode)
est store olgt_rest_a5

* ologit: Pre vs Post-911
ologit a1 `main' `controls' if post911==0 , cl(ccode)
est store olgt_pre911_a5

ologit a1 `main' `controls' if post911==1 , cl(ccode)
est store olgt_post911_a5

log on	
* TABLE A5 (Ordered logit analysis)
esttab olgt*all* olgt_rest* olgt_west* olgt_pre911* olgt_post911*, 			///
	b(3) se(3) compress noomit nobase label  star(* 0.1 ** 0.05) stats(N ll) varwidth(50) 	///
	order(1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	*slam*) mtitles		///
	coeflabels(	1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition") 		
log off	


************
* TABLE A6 *	
************
	
* ols
reg acceptable `inter_west' `controls' , cl(ccode)
est store r_interwest_a6
	
* logit
logit acceptable `inter_west' `controls' , cl(ccode)
est store lgt_interwest_a6
	
* ologit
ologit a1 `inter_west' `controls' , cl(ccode)
est store olgt_interwest_a6

log on
* TABLE A6 (Differences between western and non-western monitors)
esttab *interwest* , 				///
	b(3) se(3) compress  noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50) 	///
	order(1.islamic_opposition 1.islamic_opposition#1.westernobs	///
	Islamist_terror 1.westernobs#c.Islamist_terror				///
	nonIslamist_terror 1.westernobs#c.nonIslamist_terror		///
	1.islamic_opposition#c.Islamist_terror 						///
	1.islamic_opposition#1.westernobs#c.Islamist_terror			///
	1.islamic_opposition#c.nonIslamist_terror					///
	1.islamic_opposition#1.westernobs#c.nonIslamist_terror		///
	*slam*) keep(*sla* problems) mtitles		///
	coeflabels(	1.islamic_opposition#1.westernobs "Isl. Opp. * Western Monitors"	///
	1.westernobs#c.Islamist_terror "Isl. Terror * Western Monitors"		///	
	1.westernobs#c.nonIslamist_terror "Non-Isl. Terror * Western Monitors"				///	
	1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#1.westernobs#c.Islamist_terror 	"Isl. Terror * Isl. Opp * Western Monitors"		///
	1.islamic_opposition#1.westernobs#c.nonIslamist_terror 	"Non-Isl. Terror * Isl. Opp * Western Monitors")	
log off 
	 
	
************
* TABLE A7 *	
************
	
* ols
reg acceptable `inter_911' `controls' , cl(ccode)
est store r_inter911_a7
	
* logit
logit acceptable `inter_911' `controls' , cl(ccode)
est store lgt_inter911_a7
	
* ologit
ologit a1 `inter_911' `controls' , cl(ccode)
est store olgt_inter911_a7

log on
* TABLE A7 (Differences between pre- and post-9/11)
esttab *inter911* , 				///
	b(3) se(3) compress  noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50) 	///
	order(1.islamic_opposition 1.islamic_opposition#1.post911	///
	Islamist_terror 1.post911#c.Islamist_terror				///
	nonIslamist_terror 1.post911#c.nonIslamist_terror		///
	1.islamic_opposition#c.Islamist_terror 						///
	1.islamic_opposition#1.post911#c.Islamist_terror			///
	1.islamic_opposition#c.nonIslamist_terror					///
	1.islamic_opposition#1.post911#c.nonIslamist_terror		///
	*slam*) keep(*sla* problems) mtitles		///
	coeflabels(1.islamic_opposition#1.post911 "Isl. Opp * Post-9/11 Era"		///	
	1.post911#c.Islamist_terror "Isl. Terror * Post-9/11 Era"		///	
	1.post911#c.nonIslamist_terror "Non-Isl. Terror * Post-9/11 Era"		///	
	1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#1.post911#c.Islamist_terror 	"Isl. Terror * Isl. Opp * Post-9/11 Era"		///
	1.islamic_opposition#1.post911#c.nonIslamist_terror 	"Non-Isl. Terror * Isl. Opp * Post-9/11 Era")	
log off	 
	
	
************
* TABLE A8 *	
************

* Last 1 year
replace Islamist_terror = ln_Islamkill1yr
replace nonIslamist_terror = ln_nonIslamkill1yr

reg acceptable `main' `controls' if muslim00 > 0.3, cl(ccode)
est store r_muslim1yr_a8

* Last 5 years
replace Islamist_terror = ln_Islamkill5yr
replace nonIslamist_terror = ln_nonIslamkill5yr

reg acceptable `main' `controls' if muslim00 > 0.3 , cl(ccode)
est store r_muslim5yr_a8

logit acceptable `main' `controls' if muslim00 > 0.3 , cl(ccode)
est store lgt_muslim5yr_a8

ologit a1 `main' `controls' if muslim00 >0.3 , cl(ccode)
est store olgt_muslim5yr_a8

replace Islamist_terror = ln_Islamkill1yr
replace nonIslamist_terror = ln_nonIslamkill1yr

log on
* TABLE A8 (Sample of countries where Muslim population > 30%)
esttab r_muslim1yr_a8 r_muslim5yr_a8 lgt_muslim5yr_a8 olgt_muslim5yr_a8, 	///
	b(3) se(3) compress noomit nobase label  star(* 0.1 ** 0.05) stats(N ll r2) varwidth(50)	///
	order(1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	*slam*) mtitles		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off


************
* TABLE A9 *
************

* Only competitive elections
reg acceptable `main' `controls' if competitive ==1, cl(ccode)
est store r_competitive_a9

* Only competitive elections
logit acceptable `main' `controls' if competitive ==1, cl(ccode)
est store lgt_competitive_a9

* Only competitive elections
ologit a1 `main' `controls' if competitive ==1, cl(ccode)
est store olgt_competitive_a9

log on	
* TABLE A9 (Sample of Competitive Elections)
esttab r_competitive_a9 lgt_competitive_a9 olgt_competitive_a9, 	///
	b(3) se(3) compress noomit nobase label  star(* 0.1 ** 0.05) stats(N r2 ll) varwidth(50) ///
	order(1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	*slam*) mtitles		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off

*************
* TABLE A10 *
*************

* Exclude obs. with largest Islamist killings
reg acceptable `main' `controls' if Islamist_kill_cyear < 191 , cl(ccode)
est store r_droplargest_a10

* Exclude obs. s.t. Islamist killings > 100
reg acceptable `main' `controls' if Islamist_kill_cyear < 100 , cl(ccode)
est store r_drop100plus_a10

log on
* TABLE A10	(Exclude extreme values of terrorism)
esttab r_droplargest_a10 r_drop100plus_a10, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50)	///
	order(1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	)		///
	keep(*sla* problems)		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off


*************
* TABLE A11 *
*************	

reg acceptable `main' `controls' if western ==1 & us_security_sanx ==0, cl(ccode)
est store r_excludesanx_a11

reg acceptable `main' `controls' if western ==1 & s3un4608i > -0.2, cl(ccode)
est store r_excludeunvote_a11	
	
log on
* TABLE A11	(Exclude incumbents hostile to the US)
esttab r_excludesanx_a11 r_excludeunvote_a11, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50)	///
	order(1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	problems)		///
	///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off


*************
* TABLE A12 *
*************

local controls_additional	"c.problems muslim00 c.polity2 polity2_change ln_mortality firstmpany transitional_election postconflict pre_election_violence ln_oil lln_total_trade col_any postcoup ln_gdptotal legelec lln_netbilat s3un4608i"

reg acceptable `main' `controls_additional' if westernobs ==1, cl(ccode)
est store r_all_a12

* OLS: Pre vs Post-911
reg acceptable `main' `controls_additional' if post911==0 & westernobs ==1, cl(ccode)
est store r_pre911_a12

reg acceptable `main' `controls_additional' if post911==1 & westernobs ==1, cl(ccode)
est store r_post911_a12

reg acceptable `inter_911' `controls_additional' if westernobs ==1, cl(ccode)
est store r_inter911_a12

log on
* TABLE A12	(Additional indicators of Western donor interest)
esttab r_all_a12 r_pre911_a12 r_post911_a12 r_inter911_a12, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50)	///
	order(1.islamic_opposition 			///
	1.islamic_opposition#1.post911		///	
	Islamist_terror 1.post911#c.Islamist_terror			///
	nonIslamist_terror 1.post911#c.nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#1.post911#c.Islamist_terror 	///	
	1.islamic_opposition#c.nonIslamist_terror			///
	1.islamic_opposition#1.post911#c.nonIslamist_terror ///	
	problems)		///
	///
	keep(*sla* problems)		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition"	///
	///
	1.islamic_opposition#1.post911 "Islamic Opposition * Post-9/11 Era"		///	
	1.post911#c.Islamist_terror	"Islamist Terrorism * Post-9/11 Era"		///
	1.post911#c.nonIslamist_terror "Non-Islamist Terrorism * Post-9/11 Era"	///
	1.islamic_opposition#1.post911#c.Islamist_terror "Isl. Terror. * Isl. Oppos. * Post-9/11 Era" 	///	
	1.islamic_opposition#1.post911#c.nonIslamist_terror "Non-Isl. Terror. * Isl. Oppos. * Post-9/11 Era")
log off
	
	
*************
* TABLE A13 *
*************

reg acceptable `main' `controls' i.morg2, cl(ccode)
est store r_morgFE	

log on
* TABLE A13 (Include monitor fixed effects)
esttab r_morgFE, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50)	///
	order(*sla* problems)	///
	drop(*morg2*)			///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off


*************
* TABLE A14 *
*************

local controls 		"c.problems muslim00 c.polity2 polity2_change ln_mortality firstmpany transitional_election postconflict pre_election_violence ln_oil lln_total_trade col_any postcoup ln_gdptotal legelec"


* exclude SADC
reg acceptable `main' `controls' if morg2 !=9, cl(ccode)
est store r_SADCexcl_a14

* exclude Commonwealth
reg acceptable `main' `controls' if morg2 !=12, cl(ccode)
est store r_Commonwealthexcl_a14

* exclude CIS
reg acceptable `main' `controls' if morg2 !=16, cl(ccode)
est store r_CISexcl_a14

* exclude SADC, Commonwealth, CIS
reg acceptable `main' `controls' if morg2 !=9 & morg2 !=12 & morg2 !=16, cl(ccode)
est store r_all3excl_a14

log on
* TABLE A14 (Exclude CIS, SADC and the Commonwealth)
esttab r_*excl_a14, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) stats(N r2) varwidth(50)	///
	order(*sla* problems)	///
	keep(*sla* problems)	///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off	
	

*************
* TABLE A15 *
*************

local controls_heckman	"muslim00 c.polity2 polity2_change ln_mortality firstmpany transitional_election postconflict pre_election_violence ln_oil lln_total_trade col_any postcoup ln_gdptotal legelec"
local selection 		"c.global_election_count"

heckman acceptable `main' `controls' , sel(monitored = `selection' `main' `controls_heckman') vce(cluster ccode)
est store heck_all_a15

heckman acceptable `main' `controls' if western ==0, sel(monitored = `selection' `main' `controls_heckman') vce(cluster ccode)
est store heck_nonwest_a15

heckman acceptable `main' `controls' if western ==1, sel(monitored = `selection' `main' `controls_heckman') vce(cluster ccode)
est store heck_west_a15

log on
* TABLE A15 (Heckman analyses)
esttab heck_all_a15 heck_nonwest_a15 heck_west_a15, ///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) 	///
	stats(N ll)	varwidth(50) unstack			///
	order(problems 1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	problems)		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off
		

*************
* TABLE A16 *
*************

* All countries
reg acceptable `main' `controls', cl(newid)
est store r_all_a16

* West vs Rest
reg acceptable `main' `controls' if western==1 , cl(newid)
est store r_west_a16

reg acceptable `main' `controls' if western==0 , cl(newid)
est store r_rest_a16

* Pre vs Post-911
reg acceptable `main' `controls' if post911==0 , cl(newid)
est store r_pre911_a16

reg acceptable `main' `controls' if post911==1 , cl(newid)
est store r_post911_a16

log on
* TABLE A16 (Cluster standard errors by election)
esttab r_all_a16 r_rest_a16 r_west_a16 r_pre911_a16 r_post911_a16, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) varwidth(50)	///
	stats(N r2)	keep(*sla* problems)				///
	order(problems 1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	)		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off	
		

*************
* TABLE A17 *
*************

reg acceptable `main' `controls', cl(ccode)
keep if e(sample) ==1 

* Set seed
set seed 123456

* Randomly draw 1 Western and 1 non-Western monitoring organization per election
gen random = runiform()
bysort newid western: egen group = seq()

egen highest_west=rank(-random) if western ==1, by(newid)
tabstat random, by(highest_west) stats(N)

egen highest_nwest=rank(-random) if western==0, by(newid)
tabstat random, by(highest_nwest) stats(N)

gen highest_all = 0
replace highest_all = 1 if highest_west ==1 | highest_nwest ==1


reg acceptable `main' `controls' 	if highest_all ==1, cl(ccode)
est store r_all_a17

xtreg acceptable `main' `controls' 	if highest_all ==1, cl(ccode) fe
est store xtr_all_a17

reg acceptable `main' `controls' 	if highest_nwest ==1, cl(ccode)
est store r_rest_a17

reg acceptable `main' `controls' 	if highest_west ==1, cl(ccode)
est store r_west_a17

* OLS: Pre vs Post-911
reg acceptable `main' `controls' if highest_all ==1 & post911==0 , cl(ccode)
est store r_pre911_a17

reg acceptable `main' `controls' if highest_all ==1 & post911==1, cl(ccode)
est store r_post911_a17

log on
* TABLE A17 (Randomly select 1 Western and 1 Non-Western observer per election)
esttab r_all_a17 xtr_all_a17 r_rest_a17 r_west_a17 r_pre911_a17 r_post911_a17, 	///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) varwidth(50)	///
	stats(N r2)	keep(*sla* problems)				///
	order(problems 1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	)		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off

		
*************
* TABLE A18 *
*************

restore
preserve

gen Islamist_terror = ln_Islamkill1yr
gen nonIslamist_terror = ln_nonIslamkill1yr 

local main 			"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition"
local controls 		"c.problems muslim00 c.polity2 polity2_change ln_mortality firstmpany transitional_election postconflict pre_election_violence ln_oil lln_total_trade col_any postcoup ln_gdptotal legelec"


* Omit Pakistan
reg acceptable `main' `controls' if ccode !=770 , cl(ccode)
est store r_nopak_a18

* Omit Pakistan-1990
gen pak1990 =0
replace pak1990 =1 if year ==1990 & ccode ==770

reg acceptable `main' `controls' if pak1990 ==0, cl(ccode)
est store r_nopak90_a18

* OLS-FE:
xtreg acceptable `main' `controls', cl(ccode) fe
est store xtr_nopak90_a18

* OLS: West vs Rest
reg acceptable `main' `controls' if western==0 & pak1990 ==0 , cl(ccode)
est store r_restnopak90_a18

reg acceptable `main' `controls' if western==1 & pak1990 ==0 , cl(ccode)
est store r_westnopak90_a18

* OLS: Pre vs Post-911
reg acceptable `main' `controls' if post911==0 & pak1990 ==0 , cl(ccode)
est store r_pre911nopak90_a18

reg acceptable `main' `controls' if post911==1 & pak1990 ==0 , cl(ccode)
est store r_post911nopak90_a18

log on
* TABLE A18 (All observations since 1984 except Pakistan 1990)
esttab r_*nopak90*a18, ///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) 	///
	stats(N aic ll r2)	keep(*sla* problems) varwidth(50)			///
	order(problems 1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	)		///
	coeflabels(1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off
	

restore 


preserve

keep if year >1990

gen Islamist_attk = ln_Islamattk1yr
gen nonIslamist_attk = ln_nonIslamattk1yr

gen Islamist_terror = ln_Islamkill1yr
gen nonIslamist_terror = ln_nonIslamkill1yr 

local main 			"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition"
local controls 		"c.problems muslim00 c.polity2 polity2_change ln_mortality firstmpany transitional_election postconflict pre_election_violence ln_oil lln_total_trade col_any postcoup ln_gdptotal legelec"


*************
* TABLE A19 *
*************

local main_dpi	"(c.Islamist_terror c.nonIslamist_terror)##i.dpi_islamic_opposition"

reg acceptable `main_dpi' `controls', cl(ccode)
est store r_dpi

log on
* TABLE A19 (Alternative measure of Islamic Opposition from the DPI)
esttab r_dpi, ///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) 	///
	stats(N aic ll r2)	varwidth(50)			///
	order(1.dpi_islamic_opposition Islamist_terror nonIslamist_terror	///
	1.dpi_islamic_opposition#c.Islamist_terror 				///
	1.dpi_islamic_opposition#c.nonIslamist_terror			///
	problems )		///
	coeflabels(1.dpi_islamic_opposition "Islamic Opposition Party"	///
	1.dpi_islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.dpi_islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition")
log off


**********************
* TABLES A20-A21-A22 *
**********************

gen hi_kill_islam =0
replace hi_kill_islam =1 if Islamist_kill_cyear >0 & Islamist_kill_cyear <25
replace hi_kill_islam =2 if Islamist_kill_cyear >=25
replace hi_kill_islam =. if Islamist_kill_cyear ==.

gen hi_kill_not =0
replace hi_kill_not =1 if nonIslamist_kill_cyear >0 & nonIslamist_kill_cyear <25
replace hi_kill_not =2 if nonIslamist_kill_cyear >=25
replace hi_kill_not =. if nonIslamist_kill_cyear ==.

label define hi_kill_islam 0 "Islamist Terrorism (0)" 1 "Islamist Terrorism (Low)" 2 "Islamist Terrorism (High)"
label define hi_kill_not   0 "Non-Islamist Terrorism (0)" 1 "Non-Islamist Terrorism (Low)" 2 "Non-Islamist Terrorism (High)"

label values hi_kill_islam hi_kill_islam
label values hi_kill_not hi_kill_not

reg acceptable islamic_opposition##(i.hi*) `controls' , cl(ccode)
est store r_linear_a20

test 1.islamic_opposition#1.hi_kill_islam = 1.islamic_opposition#2.hi_kill_islam

log on
* Table A21 (Marginal effect of islamic opposition based on Table A20 Model 1)
margins, dydx(islamic_opposition) at(hi_kill_islam=(0(1)2)	hi_kill_not=0) level(90) post
*test 1.islamic_opposition#1.hi_kill_islam = 1.islamic_opposition#2.hi_kill_islam 
log off

logit acceptable islamic_opposition##(i.hi*) `controls' , cl(ccode)
est store lgt_linear_a20

log on
* Table A22 (Marginal effect of islamic opposition based on Table A20 Model 2)
margins, dydx(islamic_opposition) at(hi_kill_islam=(0(1)2)	hi_kill_not=0) level(90) post
*test 1.islamic_opposition#1.hi_kill_islam = 1.islamic_opposition#2.hi_kill_islam 
log off

log on
* Table A20 (Test of the linear interaction effect assumption)
esttab r_linear_a20 lgt_linear_a20, ///
	b(3) se(3) compress mtitles noomit nobase label  star(* 0.1 ** 0.05) 	///
	stats(N r2 ll) keep(*sla* *kill* problems) varwidth(60)			///
	order(problems *kill* problems) ///
	///
	coeflabels(1.islamic_opposition "Islamic Opposition Party"		///
	problems "Problems") 
log off	
		
	
*************
* TABLE A23 *
*************

reg acceptable `main' `controls' if igo ==1, cl(ccode)
est store r_igo_a23

* Only NGOs
reg acceptable `main' `controls' if igo ==0, cl(ccode)
est store r_ngo_a23

* IGO vs NGOs 
reg acceptable `inter_igo' `controls' , cl(ccode)
est store r_interax_a23

* IGO vs NGOs among Western observers
reg acceptable `inter_igo' `controls' if western ==1 , cl(ccode)
est store r_interax_west_a23

log on
* TABLE A23 (Studying differences between IGO and NGO monitors)
esttab r_igo_a23 r_ngo_a23 r_interax_a23 r_interax_west_a23, 		///
	varwidth(50) b(3) se(3) compress noomit nobase label star(* 0.1 ** 0.05) stats(N r2) 	///
	order(1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror			///
	*slam* *igo* problems) mtitles		///
	keep(*sla* *igo* problems)			///
	coeflabels(1.islamic_opposition "Islamic Opposition Party"		///
	Islamist_terror "Islamist Terrorism"				///
	nonIslamist_terror "Non-Islamist Terrorism"			///
	1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamic Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamic Opposition"	///
	problems "Problems"					///
	1.igo			"IGO Indicator"		///
	1.islamic_opposition#1.igo "IGO * Islamic Opposition"		///	
	1.igo#c.Islamist_terror	"IGO * Islamist Terrorism"		///
	1.igo#c.nonIslamist_terror "IGO * Non-Islamist Terrorism"	///
	1.islamic_opposition#1.igo#c.Islamist_terror "IGO * Isl. Terror. * Isl. Oppos." 	///	
	1.islamic_opposition#1.igo#c.nonIslamist_terror "IGO * Non-Isl. Terror. * Isl. Oppos.")	
log off


*************
* TABLE A24 *
*************

/*
To replicate this table refer to the separate dataset and do-file in the replication folder.
*/


	
*************
* TABLE A25 *
*************

gen islamic_opposition_nobans =islamic_opposition
replace islamic_opposition_nobans = 0 if Banned_Islamist ==1 | Boycott ==1

local main_nobans	"(c.Islamist_terror c.nonIslamist_terror)##i.islamic_opposition_nobans"

* OLS: All countries
reg acceptable `main_nobans' `controls', cl(ccode)
est store all_nobans

* OLS-FE: All countries
xtreg acceptable `main_nobans' `controls', cl(ccode) fe
est store FE_nobans

* OLS: West vs Rest
reg acceptable `main_nobans' `controls' if western==1 , cl(ccode)
est store west_nobans

reg acceptable `main_nobans' `controls' if western==0 , cl(ccode)
est store nonwest_nobans

* OLS: Pre vs Post-911
reg acceptable `main_nobans' `controls' if post911==0 , cl(ccode)
est store pre911_nobans

reg acceptable `main_nobans' `controls' if post911==1 , cl(ccode)
est store post911_nobans

log on
* TABLE A25 (Recode Islamic opposition as zero if Islamists are banned or boycotting the election)
esttab *nobans, b(3) se(3) compress mtitles noomit nobase star(* 0.1 ** 0.05) 	///
	stats(N r2)	keep(*sla* problems) varwidth(50)		///
	order(problems 1.islamic_opposition_nobans			///
	Islamist_terror nonIslamist_terror)	///
	///
	coeflabels(1.islamic_opposition_nobans "Islamist Opposition Party"		///
	Islamist_terror "Islamist Terrorism"				///
	nonIslamist_terror "Non-Islamist Terrorism"			///
	1.islamic_opposition_nobans#c.Islamist_terror "Islamist Terrorism * Islamist Opposition"	///
	1.islamic_opposition_nobans#c.nonIslamist_terror "Non-Islamist Terrorism * Islamist Opposition"	///
	problems "Problems") 
log off


*************
* TABLE A26 *
*************

local main_attk		"(c.Islamist_attk   c.nonIslamist_attk)##i.islamic_opposition"
local main_attkwest	"(c.Islamist_attk   c.nonIslamist_attk)##i.islamic_opposition##i.western"
local main_attk911	"(c.Islamist_attk   c.nonIslamist_attk)##i.islamic_opposition##i.igo"

* OLS: All countries
reg acceptable `main_attk' `controls', cl(ccode)
est store all_a26

* OLS-FE: All countries
xtreg acceptable `main_attk' `controls', cl(ccode) fe
est store FE_a26

* OLS: West vs Rest
reg acceptable `main_attk' `controls' if western==1 , cl(ccode)
est store west_a26

reg acceptable `main_attk' `controls' if western==0 , cl(ccode)
est store nonwest_a26

* OLS: Pre vs Post-911
reg acceptable `main_attk' `controls' if post911==0 , cl(ccode)
est store pre911_a26

reg acceptable `main_attk' `controls' if post911==1 , cl(ccode)
est store post911_a26

* Interactions
reg acceptable `main_attkwest' `controls'  , cl(ccode)
//est store interwest_a26

reg acceptable `main_attk911' `controls'  , cl(ccode)
//est store inter911_a26

log on
* TABLE A26 (Measure terrorism by the number of attacks)
esttab *a26, b(3) se(3) compress mtitles noomit nobase star(* 0.1 ** 0.05) 	///
	stats(N r2)	keep(*sla* problems) varwidth(50)				///
	///
	coeflabels(1.islamic_opposition "Islamist Opposition Party"		///
	Islamist_attk "Islamist Attacks"				///
	nonIslamist_attk "Non-Islamist Attacks"			///
	1.islamic_opposition#c.Islamist_attk "Islamist Attacks * Islamist Opposition"	///
	1.islamic_opposition#c.nonIslamist_attk "Non-Islamist Attacks * Islamist Opposition"	///
	problems "Problems") 
log off	 

	 

*************
* TABLE A27 *
*************

* Pre vs Post-911 among Western monitors
reg acceptable `main' `controls' if post911==0 & western==1, cl(ccode)
est store pre911_a27

reg acceptable `main' `controls' if post911==1 & western==1, cl(ccode)
est store post911_a27

reg acceptable `inter_911' `controls' if western ==1, cl(ccode)
est store interax_911_a27

log on
* Table A27 (Pre vs Post-9/11 era effects among Western monitors)
esttab *a27, b(3) se(3) compress mtitles noomit nobase star(* 0.1 ** 0.05) 	///
	stats(N r2)	keep(*sla* problems) varwidth(50)				///
	order(problems 1.islamic_opposition Islamist_terror nonIslamist_terror	///
	1.islamic_opposition#c.Islamist_terror 				///
	1.islamic_opposition#c.nonIslamist_terror)			///
	///
	coeflabels(1.islamic_opposition "Islamist Opposition Party"		///
	Islamist_terror "Islamist Terrorism"				///
	nonIslamist_terror "Non-Islamist Terrorism"			///
	1.islamic_opposition#c.Islamist_terror "Islamist Terrorism * Islamist Opposition"	///
	1.islamic_opposition#c.nonIslamist_terror "Non-Islamist Terrorism * Islamist Opposition"	///
	1.islamic_opposition#1.post911 "Islamist Opposition Party * Post-9/11"	///
	1.post911#c.Islamist_terror "Islamist Terrorism * Post-9/11"				///
	1.post911#c.nonIslamist_terror "Non-Islamist Terrorism * Post-9/11"		///
	1.islamic_opposition#1.post911#c.Islamist_terror "Islamist Terrorism * Islamist Opposition * Post-9/11"	///
	1.islamic_opposition#1.post911#c.nonIslamist_terror "Non-Islamist Terrorism * Islamist Opposition * Post-9/11"	///
	problems "Problems")
log close	 
		 
	 
